home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!news
- From: ave@ix.netcom.com(Alexander Berdichevsky )
- Newsgroups: comp.lang.c++
- Subject: Re: Question about visibility of local variables
- Date: 5 Mar 1996 12:37:04 GMT
- Organization: Netcom
- Message-ID: <4hhchg$g0p@dfw-ixnews1.ix.netcom.com>
- References: <4hfkpc$9em@guardian.forbin.com>
- NNTP-Posting-Host: ix-prn1-11.ix.netcom.com
- X-NETCOM-Date: Tue Mar 05 6:37:04 AM CST 1996
-
- In <4hfkpc$9em@guardian.forbin.com> genesis@forbin.com (Dances with
- Demons) writes:
- >
- >I am in the process of learning C++ which surprised me in being
- >as awesome as everyone kept telling me. It is literally better
- >than anything I ever expected. I ran into one dark area for me
- >in the area of automatic variables.
- > It said in the book I'm studying, "Object-Oriented Programming
- >in C++, by Robert Lafore", that when a function is executed, the
- >and the variable is defined, it will continue to exist until the
- >function is exited. When this happens, the memory that the variable
- >is freed up and is used by other variables/function calls, etc.
- >
- >The question is: When you define a variable in main(), and call
- another
- >function, or even when defining a local variable in a function that
- calls
- >another function, why are the local variables not destroyed.
-
- All local variables are destroyed after the function is done (after
- return clause). When the function calls another function it is not done
- yet.
-
- If it is not enough feel free to email more detail question to me.
-
- Alex
-
-